<meta charset="utf-8">
<input id="d5"/>
<br/><br/>
<input type="button" value="1" id="d1"/>
<input type="button" value="2" id="d2"/>
<input type="button" value="3" id="d3"/>
<input type="button" value="c" id="d4"/>

<script>
    d1.onclick  = function(){
        d5.value = d5.value + "1";
    }
    d2.onclick  = function(){
        d5.value = d5.value + "2";
    }
    d3.onclick  = function(){
        d5.value = d5.value + "3";
    }
    d4.onclick  = function(){
        d5.value = "";
    }
</script>